package Day03;

public class Practice {
    public static void main(String[] args) {
        System.out.println(1+1);//2
        System.out.println(0.5/2);//0.25
        System.out.println(2/4);//0
        System.out.println(4/2);//2
        System.out.println(5%2);//1
        System.out.println(4%2);//0
        System.out.println("--------------------------------");

        int a1=2,b1=2;
        a1++;
        ++b1;
        System.out.println("a1的值为"+a1);//3
        System.out.println("b1的值为"+b1);//3
        int a2,b2;
        a2=a1++;
        b2=++b1;
        System.out.println("此时a1的值为"+a1);//4
        System.out.println("此时b1的值为"+b1);//4
        System.out.println("a2的值为"+a2);//3
        System.out.println("b2的值为"+b2);//4
        System.out.println("----------------------------");

        int a3=1,b3=2,c3=1;
        boolean a4 = a3>b3,b4=b3>c3;
        System.out.println("a4的值为"+a4);//f
        System.out.println("b4的值为"+b4);//t
        System.out.println(a3>=b3);//f
        System.out.println(a3>=c3);//t
        System.out.println(a3==c3);//t
        System.out.println("a3>b3的结果为"+(a3>=b3));//f
        boolean a5 =a3>=b3 && b3>=c3;
        System.out.println(a5);//f
        System.out.println(a3>=b3 || b3>=c3);//t
        System.out.println(!(a3>=b3));//t
        System.out.println("----------------------------------");

        System.out.println(a3>=b3 && a3++>=2);//f+t=f,第一个条件短路，第二个条件不执行
        System.out.println("a3+1的值为"+(a3+1));//2，a3的,1没有变化，1+1=2
        System.out.println(b3>=c3 && ++a3>=2);//t+t=t,两个条件均执行，++a3=2,a3自增1=2
        System.out.println("此时a3的值为"+a3);//2
        System.out.println("-----------------------------");


        int a6=1,b6=2;
        System.out.println("a6=a6*3的值为"+(a6*=3));//3
        System.out.println(a6);//3
        int max =a6>b6?a6:b6;
        System.out.println(max);//3
        System.out.println("最小值为"+(a6<b6?a6:b6));//最小值b6=2
        System.out.println("-------------------------");

        int price=1100;
        if (price>=2000){
            System.out.println("五折结算价格为"+(price*=0.5));
        }else if (price>=1500){
            System.out.println("七折结算价格为"+(price*=0.7));
        }else if (price>=1000){
            System.out.println("八折结算价格为"+(price*=0.8));
        }else if (price>=500){
            System.out.println("九折结算价格为"+(price*=0.9));
        }else {
            System.out.println("未打折结算价格为"+price);
        }

        System.out.println("-----------以下为拓展练习-----------");
        System.out.println("练习1");
        int a7=6,b7=8;
        int max7=a7>b7?a7:b7;
        System.out.println("最大值为"+max7);
        System.out.println("最大值为"+(a7>b7?a7:b7));
        if (a7>b7){
            System.out.println(a7);
        }else {
            System.out.println(b7);
        }
        System.out.println("练习2");
        int year=1989;
        if (year%4==0 && year%100!=0){
            System.out.println(year+"年是闰年");
        }else{
            System.out.println(year+"年是平年");
        }
        System.out.println("练习3");
        int score =0;
        if (score<0 || score>100){
            System.out.println(score+"分成绩不合法");
        }else if (score>=90){
            System.out.println(score+"分成绩等级为A");
        }else if (score>=80){
            System.out.println(score+"分成绩等级为B");
        }else if (score>=60){
            System.out.println(score+"分成绩等级为C");
        }else {
            System.out.println(score+"分成绩等级为D");
        }

    }
}
